def binarySearch(alist, item):
    first = 0
    last = len(alist) - 1

    while first <= last:
        mid = (first + last)//2
        print 'mid=',mid
        if alist[mid] > item:
            last = mid - 1
        elif alist[mid] < item:
            first = mid + 1
        else:
            return mid
    return -1

test = [0, 1, 2, 3, 8, 13, 17, 19, 32, 42]
print(binarySearch(test, 17))